local id = "hx_clear_shell"
local thread
local shells = {"singingshell_octave3", "singingshell_octave5", "singingshell_octave4"}
local function TIPS(content, color)
    TIP("隐藏贝壳", color or "green", content)
end

local function StopThread(message)
    GLOBAL.KillThreadsWithID(id)
    thread = nil
    for _, ent in pairs(PlayerFindEnts(nil, {"singingshell"}))do
        if table.contains(shells, ent.prefab) then
            ent:Show()
        end
    end
    TIPS(message or "结束", "red")
end

local function fn()
    if thread then
        StopThread()
    else
        TIPS("开始")
        thread = GLOBAL.StartThread(function()
            while thread do
                Sleep(1)
                for _, ent in pairs(PlayerFindEnts(16, {"singingshell"}))do
                    if table.contains(shells, ent.prefab) then
                        ent:Hide()
                    end
                end
            end
        end, id)
    end
end



local btn = GetModConfigData("sw_hideshell")
if btn == "biubiu" then
    DEAR_BTNS:AddDearBtn(GLOBAL.GetInventoryItemAtlas("hermit_pearl.tex"), "hermit_pearl.tex", "隐藏贝壳", "帮奶奶打捞贝壳堆时使用", true,fn)  
end

AddBindBtn("sw_hideshell", fn)